[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
stricmp() Compare Two Strings, Case Insensitive
#include <string.h> Required for declarations only
int stricmp(string1,string2);
const char *string1; First string
const char *string2; Second string
stricmp() compares 'string1' and 'string2' lexicographically ( 'a' is
less than 'b', 'b' is equal to 'b', and 'c' is greater than 'b').
stricmp() is case-insensitive, so 'a' is equal to 'A'.
Returns: A value indicating the relationship between the two
strings:
Comparison Returned
'string1' < 'string2' < 0
'string1' == 'string2' 0
'string1' > 'string2' > 0
Notes: stricmp() is identical to strcmpi()(used with other
compilers).
stricmp() expects to operate on null-terminated
strings. No overflow checking is done when strings
are copied or appended.
-------------------------------- Example ---------------------------------
In this example, the two strings compared are equivalent.
#include <string.h>
#include <stdio.h>
char str1[25] = "a quick brown fox";
char str2[25] = "A Quick Brown Fox";
int rslt;
main()
{
rslt = stricmp(str1,str2);
if (rslt == 0)
printf("strings are identical");
else
printf("strings do not match");
}
See Also:
strcmp()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson